﻿using ReactiveUI.Fody.Helpers;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using S7.Net.Types;
using DateTime = System.DateTime;

namespace Common.ViewModels
{
  
    public class 工件: ViewModelNotify
    {
        /// <summary>
        /// 工件名称
        /// </summary>
        private string m_Name;

        public string Name
        {
            get => m_Name;
            set
            {
                if (m_Name != value)
                {
                    return;
                }
                m_Name = value;
                this.RaisePropertyChanged();
            }
        }

        private int m_Num;

        /// <summary>
        /// 工件编号
        /// </summary>
        [JsonIgnore]
        public int Num
        {
            get => m_Num;
            set
            {
                m_Num=value;
                this.RaisePropertyChanged();
            }
        }

        /// <summary>
        /// 工件配方
        /// </summary>
        [Reactive]
        public 配方 配方 { get; set; }

        /// <summary>
        /// 工位信息(小车要经历的工作列表)
        /// </summary>
        [JsonIgnore]
        [Reactive]
        public List<工位类型> WorkStations { get; set; } = new ();

        /// <summary>
        /// 工件步骤(根据工件步骤得出当前工件工作到哪一步了)
        /// </summary>
        [Reactive]
        [JsonIgnore]
        public int Step { get; set; } = 0;

        /// <summary>
        /// 当前工位工作信息
        /// </summary>
        [Reactive]public StationWorkInfo StationWorkInfo { get; set; }



        #region 主通道时使用

        private bool m_IsWaitMove  =false;

        /// <summary>
        /// 是否需要移动,当需要移动时进行判断
        /// </summary>
        [JsonIgnore]
        public bool IsWaitMove
        {
            get => m_IsWaitMove;
            set
            {
                m_IsWaitMove=value;
                this.RaisePropertyChanged();
            }
        }

        //private bool m_IsInMain

        /// <summary>
        /// 开始时间(根据开始时间排出优先级)
        /// </summary>
        public DateTime StartTime { get; set; }

        /// <summary>
        /// 当前槽位(当前工作所在槽位)
        /// </summary>
        public WorkStation CurrentWorkStation { get; set; }

        /// <summary>
        /// 工件当前站点(搬运,当前)
        /// </summary>
       public Station CurrentStation { get; set; }

        /// <summary>
        /// 工件下一个站点(去往下料就完事了)
        /// </summary>
         public Station NextStation { get; set; }

        /// <summary>
        /// 工件要去的槽位(不下料的时候使用)
        /// </summary>
        public WorkStation NextWorkStation { get; set; }

        /// <summary>
        /// 临时工位(临时用)
        /// </summary>
        public WorkStation TempWorkStation { get; set; }

        /// <summary>
        /// 临时站点(在两个组之间使用)
        /// </summary>
        public Station TempStation { get; set; }

        private 工件状态 m_工件状态;

        public 工件状态 工件状态
        {
            get => m_工件状态;
            set
            {
                m_工件状态=value; 
                this.RaisePropertyChanged();
            }
        }

        #endregion

        #region 片区时使用

        #endregion

        //public 
    }

    /// <summary>
    /// 
    /// </summary>
    public enum 工件状态
    {
        None,
        等待运输中,
        运输中,
        工作中,
    }

    public class 工件输送信息 : ViewModelNotify
    {
        /// <summary>
        /// 工件当前所在站点
        /// </summary>
        public Station CurrentStation { get; set; }

        /// <summary>
        /// 工件要去的槽位
        /// </summary>
        public WorkStation WorkStation { get; set; }

        //public Station Sta

    }

    
}
